package com.example.sxt_practise.IO;

import java.io.*;

/**
 * @author gaofeng
 * @date 2022年05月10日 21:42
 */
public class DataStreamTest {
    public static void main(String[] args) throws IOException {
 /*       ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream() ;
        DataOutputStream outputStream = new DataOutputStream(new BufferedOutputStream(byteArrayOutputStream)) ;
        outputStream.writeUTF("编码辛酸泪,谁解其中味道");
        outputStream.writeInt(18);
        outputStream.writeBoolean(true);
        outputStream.flush();

        byte[] data = byteArrayOutputStream.toByteArray();
        DataInputStream inputStream = new DataInputStream(new BufferedInputStream(new ByteArrayInputStream(data))) ;
        System.out.println(inputStream.readUTF());
        inputStream.readInt() ;
        inputStream.readBoolean() ;*/

        System.out.println("**********************************************************************************");

        InputStream inputStream = new FileInputStream(new File("baidu.txt")) ;
        DataInputStream dataOutputStream = new DataInputStream(new BufferedInputStream(inputStream)) ;
        int len = -1 ;
        byte[] bytes = new byte[1024 * 2] ;
        while ((len = inputStream.read()) != -1) {
            System.out.println(dataOutputStream.read());
        }
    }
}
